﻿/****************************************************************
  Author:  Ievgenii Nazaruk, ievgenii.nazaruk@gmail.com 
 License:  Microsoft Public License (Ms-PL)
          ( http://www.opensource.org/licenses/ms-pl.html or
            http://www.microsoft.com/opensource/licenses.mspx )
*****************************************************************/

using System.Collections.Generic;

namespace TableParsers
{
    public class WaitListTableEntry
    {
        public ClassName ClassName = null;
        public ClassTime ClassTime = null;
        public int ClassId = 0;
    }

    public class WaitListTable: List<WaitListTableEntry>
    {
        public static WaitListTable Fetch(WebLayer.LoginToken loginToken)
        {
            WebPageParser.WebPageCache pageCache = new WebPageParser.WebPageCache();
            pageCache.LoginToken = loginToken;

            return Fetch(pageCache);
        }
        public static WaitListTable Fetch(WebPageParser.WebPageCache pageCache)
        {
            WebPageParser.ReservationsWebPage webPage = pageCache.GetPage<WebPageParser.ReservationsWebPage>();

            WaitListTable waitListTable = new WaitListTable();
            foreach (WebPageParser.WaitListTableEntry webEntry in webPage.WaitListTableContent)
            {
                WaitListTableEntry memEntry = new WaitListTableEntry();

                memEntry.ClassName = ClassNameParser.ParseClassName(webEntry.Class);
                memEntry.ClassTime = ClassTimeParser.ParseWaitListEntry(webEntry.Date);
                //memEntry.ClassId = Int32.Parse(webEntry.Cancel);

                waitListTable.Add(memEntry);
            }

            return waitListTable;
        }
    }
}
